import Layout from '@/page/index/index.vue';
import Store from '@/store/';

export default [
    {
        path: '/wel',
        component: () =>
            Store.getters.isMacOs ? import('@/mac/index.vue') : import('@/page/index/index.vue'),
        redirect: '/wel/index',
        children: [
            {
                path: 'index',
                name: '首页',
                meta: {
                    i18n: 'dashboard',
                },
                component: () => import(/* webpackChunkName: "views" */ '@/views/wel/index.vue'),
            },
            {
                path: 'dashboard',
                name: '控制台',
                meta: {
                    i18n: 'dashboard',
                    menu: false,
                },
                component: () => import(/* webpackChunkName: "views" */ '@/views/wel/dashboard.vue'),
            },
        ],
    },
    {
        path: '/test',
        component: Layout,
        redirect: '/test/index',
        children: [
            {
                path: 'index',
                name: '测试页',
                meta: {
                    i18n: 'test',
                },
                component: () => import(/* webpackChunkName: "views" */ '@/views/util/test.vue'),
            },
        ],
    },
    {
        path: '/dict-horizontal',
        component: Layout,
        redirect: '/dict-horizontal/index',
        children: [
            {
                path: 'index',
                name: '字典管理',
                meta: {
                    i18n: 'dict',
                },
                component: () =>
                    import(/* webpackChunkName: "views" */ '@/views/util/demo/dict-horizontal.vue'),
            },
        ],
    },
    {
        path: '/dict-vertical',
        component: Layout,
        redirect: '/dict-vertical/index',
        children: [
            {
                path: 'index',
                name: '字典管理',
                meta: {
                    i18n: 'dict',
                },
                component: () =>
                    import(/* webpackChunkName: "views" */ '@/views/util/demo/dict-vertical.vue'),
            },
        ],
    },
    {
        path: '/info',
        component: Layout,
        redirect: '/info/index',
        children: [
            {
                path: 'index',
                name: '个人信息',
                meta: {
                    i18n: 'info',
                },
                component: () => import(/* webpackChunkName: "views" */ '@/views/system/userinfo.vue'),
            },
        ],
    },
    {
        path: '/work/process/leave',
        component: Layout,
        redirect: '/work/process/leave/form',
        children: [
            {
                path: 'form/:processDefinitionId',
                name: '请假流程',
                meta: {
                    i18n: 'work',
                },
                component: () =>
                    import(/* webpackChunkName: "views" */ '@/views/work/process/leave/form.vue'),
            },
            {
                path: 'handle/:taskId/:processInstanceId/:businessId',
                name: '处理请假流程',
                meta: {
                    i18n: 'work',
                },
                component: () =>
                    import(/* webpackChunkName: "views" */ '@/views/work/process/leave/handle.vue'),
            },
            {
                path: 'detail/:processInstanceId/:businessId',
                name: '请假流程详情',
                meta: {
                    i18n: 'work',
                },
                component: () =>
                    import(/* webpackChunkName: "views" */ '@/views/work/process/leave/detail.vue'),
            },
        ],
    },
<#--<#function generateRoute route>
    <#local result = "">
    <#local result = result + "{
    path: '${route.path}',
    name: '${route.name}',">

    <#if route.component??>
        <#local result = result + "
    component: () => import('${route.component}'),">
    </#if>

    <#if route.meta??>
        <#local result = result + "
    meta: ${route.meta}">
        <#if route.children??>
            <#local result = result + ",">
        </#if>
    </#if>

    <#if route.children??>
        <#local result = result + "
    children: [">
        <#list route.children as child>
            <#local result = result + generateRoute(child)>
            <#if child_has_next>
                <#local result = result + ",">
            </#if>
        </#list>
        <#local result = result + "
    ]">
    </#if>

    <#local result = result + "
  }">
    <#return result>
</#function>

<#list routes as route>
    <#if route??>
        ${generateRoute(route)}<#if route_has_next>,</#if>
    </#if>
</#list>-->


<#-- 递归宏：生成单个路由的格式化输出 -->
<#macro formatRoute route indent=0 isLast=false>
    <#local spaces = ""/>
    <#list 0..<indent as i>
        <#local spaces = spaces + "  "/>
    </#list>
    <#local comma = isLast?then("", ",")>
    ${spaces}{
    ${spaces}  path: '${route.path}',
    ${spaces}  name: '${route.name}',<#if route.component??>
    ${spaces}  component: () => import('${route.component}'),</#if><#if route.meta??>
    ${spaces}  meta: ${route.meta},</#if><#if route.children??>
    ${spaces}  children: [
    <#list route.children as child>
        <@formatRoute route=child indent=indent+2 isLast=!child?has_next />
    </#list>
    ${spaces}  ]</#if>
    ${spaces}}${comma}
</#macro>

<#-- 主模板：生成整个 routes 数组 -->
<#list routes as route>
    <@formatRoute route=route indent=1 isLast=!route?has_next />
</#list>
];
